package com.example.SimpleGateway.controller;

import com.example.SimpleGateway.model.TestData;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by zhanggq on 2017/12/26.
 */
@RestController
@RequestMapping(value = "/api")
public class ApiController {

    /**
     * @testURL http://localhost:8088/simpleGW/api/testApi?query_key=zhangsan
     * @param queryKey
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/testApi", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
    public ResponseEntity getTextByKey(@RequestParam("query_key") String queryKey) throws Exception {
        TestData jsonData = new TestData();
        jsonData.setTitle("title1");
        jsonData.setBody("body1");

        return ResponseEntity.ok(jsonData);
    }
}
